let cookie2 = "18f473e3f212e7db4273a75115af2971";
let token = "ee95fe1e7a53f";
var request = require("request")
var http = require("http")
var requestPost = require("../common/Request").RequestPost
var utils = require("../common/utils")

class test {
    async test() {
        let url = 'https://pub.alimama.com/common/adzone/selfAdzoneCreate.json';
        var t = new Date().getTime()

        var params = {
            'tag': '29',
            'gcid': "7",
            'siteid': '112300025',
            'selectact': 'add',
            'newadzonename': '888888',
            't': t,
            '_tb_token_': token,
            'pvid': '10_220.200.59.244_622_' + t,
        }

        var cookies = {
            '_tb_token_': token,
            'v': '0',
            'cookie2': cookie2,
        };
        var cookie_val = utils.formatCook(cookies);
        var headers = {
            'origin': 'https://pub.alimama.com',
            'authority': 'pub.alimama.com',
            'method': 'POST',
            'path': '/common/adzone/selfAdzoneCreate.json',
            'referer': 'https://pub.alimama.com/promo/search/index.htm?q=asd&_t=1537547202752',
            'x-requested-with': 'XMLHttpRequest',
            "Cookie":cookie_val
        }

        var j = request.jar()
        request = request.defaults({jar:j})
        console.log("cookie_val",cookie_val)
        let c = request.cookie(cookie_val)



        console.log("c",c)
        // let isLogin = await requestPost(url, params, headers);
        // console.log("isLogin",isLogin)
        request.post('https://pub.alimama.com/common/adzone/selfAdzoneCreate.json', {jar: j,form: params,headers}, function optionalCallback(err, httpResponse, body) {
            if (err) {
                return console.error('upload failed:', err);
            }
            console.log('Upload successful!  Server responded with:', body);
        });
    }


}

var aaa = new test();
aaa.test()
